package com.itheima;

import com.itheima.domin.dto.LoginDTO;
import com.itheima.domin.pojo.Emp;
import com.itheima.domin.query.LogQuery;
import com.itheima.domin.vo.Result;
import com.itheima.service.EmpService;
import com.itheima.service.ReportService;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 登录
 *
 * @Author:上官徵羽
 * @Date: 2025/07/15 18:18
 * @Description TODO 今日内容:
 */
@RestController
@Slf4j
@ToString
@RequestMapping
public class UserLogin {
    @Autowired
    private ReportService reportService;
    @Autowired
    private EmpService empService;

    /** 登录 */
    @PostMapping(value = "/login")
    public Result userLogin(@RequestBody LoginDTO loginDTO){
        log.info("UserLogin userLogin:{}", loginDTO);
        return Result.success(empService.empLogin(loginDTO.getUsername(),loginDTO.getPassword()));
    }

    /** 日志统计列表 */
    @GetMapping("/log/page")
    public Result selectLog(LogQuery logQuery){
        return Result.success(reportService.logInfo(logQuery));
    }
}
